Skip to content

Fix sheets ignoring their detents#58

Merged
colemancda merged 2 commits into
masterfrom
fix/sheet-detents
Jul 24, 2026
Merged

Fix sheets ignoring their detents#58
colemancda merged 2 commits into
masterfrom
fix/sheet-detents

Conversation

@colemancda

Copy link
Copy Markdown
Member

A full-size .sheet came up as a short strip at the bottom of the screen instead of covering it.

Cause

The Swift side has emitted a detents prop since sheets landed, but the interpreter never read it. Every sheet was therefore the same default ModalBottomSheet, and a Material sheet is only as tall as its content — so the sheet wrapped its two small views and stopped there. The same omission made .presentationDetents([.medium]) a no-op: both sheets in the gallery rendered identically.

Fix

Read the detents and size the sheet accordingly:

  • no detents (SwiftUI's default) or .large → fills the height, and skips the partially-expanded stop since there's no partial detent to rest at
  • .medium only → rests at half height
  • both → starts partial, expands to full

The height has to be applied to the sheet's content (fillMaxHeight), not just the sheet state: skipPartiallyExpanded only chooses which anchor the sheet settles on, it doesn't make short content occupy the screen. That distinction is what the original code was missing.

Verification

  • swift test — added the missing emission test (a declared .medium reaches the node; no detents emits an empty array, which the interpreter reads as full height), 97 total passing
  • Emulator, before/after screenshots on the Sheet screen: the full-size sheet went from a ~20% strip to covering the screen, and the medium sheet now rests at half height with the presenting screen visible above it — the two are finally distinguishable.

@colemancda
colemancda merged commit 022b05e into master Jul 24, 2026
6 checks passed
@colemancda
colemancda deleted the fix/sheet-detents branch July 24, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant